#include "../../include/shape/Circle.h"

void CircleClass::draw()
{
	if (getlinecolor() != m_color) setlinecolor(m_color);
	if (m_ifFill) {
		if (getfillcolor() != m_fillColor) setfillcolor(m_fillColor);
		fillcircle(coord.x, coord.y, coord.radius);
		outtextxy(coord.x, coord.y, m_data);
	}
	else {
		circle(coord.x, coord.y, coord.radius);
		outtextxy(coord.x, coord.y, m_data);
	}
}

void CircleClass::move(Dir dir, int distance)
{
	LPRECT lpRect = new tagRECT();
	GetWindowRect(GetHWnd(), lpRect);
	int length = lpRect->right - lpRect->left;
	int height = abs(lpRect->bottom - lpRect->top);
	switch (dir)
	{
	case Dir::Left:
		coord.x -= distance;
		if (coord.x <= coord.radius) coord.x = coord.radius;
		break;
	case Dir::Top:
		coord.y -= distance;
		if (coord.y <= coord.radius) coord.y = coord.radius;
		break;
	case Dir::Right:
		coord.x += distance;
		if (coord.x >= length - coord.radius) coord.x = length - coord.radius;
		break;
	case Dir::Bottom:
		coord.y += distance;
		if (coord.y >= height - coord.radius) coord.y = height - coord.radius;
		break;
	default:
		break;
	}
}
